package com.teacher.pc.controller;


import com.teacher.common.CommonResult;
import com.teacher.pojo.dto.goodthingstask.GoodThingsAddDto;
import com.teacher.pojo.dto.goodthingstask.GoodThingsUpdateDto;
import com.teacher.pojo.vo.goodthingstask.GoodThingsGetVo;
import com.teacher.service.IGoodThingsTaskService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 好人好事-一条1分 前端控制器
 * </p>
 *
 * @author zfm
 * @since 2021-08-11
 */
@RestController
@RequestMapping("/pc/good-things-task")
public class GoodThingsTaskController {
    @Autowired
    private IGoodThingsTaskService iGoodThingsTaskService;


    /**
     * 发起好人好事
     *
     * @param dto
     * @return
     */
    @PostMapping
    @ApiOperation("发起好人好事审批流程")
    public CommonResult<String> add(@RequestBody @Validated GoodThingsAddDto dto) {
        return iGoodThingsTaskService.add(dto);
    }

    /**
     * 更新流程
     *
     * @param dto
     * @return
     */
    @PutMapping
    @ApiOperation("更新流程")
    public CommonResult<String> update(@RequestBody @Validated GoodThingsUpdateDto dto) {
        return iGoodThingsTaskService.updateInfo(dto);
    }

    /**
     * 获取详情
     *
     * @return
     */
    @GetMapping("/{flowId}")
    @ApiOperation("获取详情")
    public CommonResult<GoodThingsGetVo> getDetails(@PathVariable("flowId") Long id) {
        return iGoodThingsTaskService.getDetails(id);
    }
}

